 var hasOwn = Object.prototype.hasOwnProperty;

 function filter(arr, fn, self) {
   if (arr.filter) return arr.filter(fn, self);
   if (void 0 === arr || null === arr) throw new TypeError;
   if ('function' != typeof fn) throw new TypeError;
   var ret = [];
   for (var i = 0; i < arr.length; i++) {
     if (!hasOwn.call(arr, i)) continue;
     var val = arr[i];
     if (fn.call(self, val, i, arr)) ret.push(val);
   }
   return ret;
 };

 var classCallCheck = function(instance, Constructor) {
   if (!(instance instanceof Constructor)) {
     throw new TypeError("Cannot call a class as a function");
   }
 };

 var createClass = function() {
   function defineProperties(target, props) {
     for (var i = 0; i < props.length; i++) {
       var descriptor = props[i];
       descriptor.enumerable = descriptor.enumerable || false;
       descriptor.configurable = true;
       if ("value" in descriptor) descriptor.writable = true;
       Object.defineProperty(target, descriptor.key, descriptor);
     }
   }

   return function(Constructor, protoProps, staticProps) {
     if (protoProps) defineProperties(Constructor.prototype, protoProps);
     if (staticProps) defineProperties(Constructor, staticProps);
     return Constructor;
   };
 }();

 var Manager = function() {
   function Manager(data, count) {
     classCallCheck(this, Manager);

     this.data = data;
     this.count = count;
   }

   createClass(Manager, [{
     key: 'getChildren',
     value: function getChildren(value) {
       return filter(this.data, function(one) {
         return one.parent === value;
       });
     }
   }, {
     key: 'getFirstColumn',
     value: function getFirstColumn() {
       return filter(this.data, function(one) {
         return !one.parent || one.parent === 0;
       });
     }
   }, {
     key: 'getColumns',
     value: function getColumns(value) {
       var datas = [];
       for (var i = 0; i < this.count; i++) {
         if (i === 0) {
           datas.push(this.getFirstColumn());
         } else {
           // 没有数据时，取得上一级的第一个
           if (!value[i]) {
             var topValue = datas[i - 1][0].value;
             datas.push(this.getChildren(topValue));
           } else {
             datas.push(this.getChildren(value[i - 1]));
           }
         }
       }
       return datas;
     }
   }]);
   return Manager;
 }();

 // export default Manager;
